﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Framework.DynamicApiController.Test
{
	/// <summary>
	/// 动态API使用示例
	/// </summary>
	[Service("AppleAppService")]
	public class AppleAppService
	{
		private static readonly Dictionary<int, string> Apples = new Dictionary<int, string>()
		{
			[1] = "Big Apple",
			[2] = "Small Apple"
		};

		/// <summary>
		/// Get An Apple.
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		[HttpGet("{id:int}")]
		public string Get(int id)
		{
			if (Apples.ContainsKey(id))
			{
				return Apples[id];
			}
			else
			{
				return "No Apple!";
			}
		}

		/// <summary>
		/// Get All Apple.
		/// </summary>
		/// <returns></returns>
		//[NotApiResult]
		public IEnumerable<string> Get()
		{
			return Apples.Values;
		}
	}
}
